package com.gexiaobao.pigeon.ui.adapter

import android.widget.ImageView
import androidx.appcompat.widget.AppCompatImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.flyjingfish.openimagelib.OpenImage
import com.flyjingfish.openimagelib.enums.MediaType
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.util.ImageLoaderManager

/**
 * @author:hxw
 * @date  :2023/2/2
 * @desc  :
 */
class ProductIntroduceImageAdapter(data: ArrayList<String>) :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_product_introduce_image, data) {

    override fun convert(holder: BaseViewHolder, item: String) {
        val ivImage = holder.getView<AppCompatImageView>(R.id.iv_item_product_image)
        ImageLoaderManager.loadImage(context, item, ivImage)

        holder.itemView.setOnClickListener {
            OpenImage.with(context)
                .setClickImageView(ivImage)
                .setSrcImageViewScaleType(ImageView.ScaleType.CENTER_CROP, true)
                .setImageUrl(item[holder.layoutPosition].toString(), MediaType.IMAGE).show()
        }
    }
}